package homework;

import java.util.Collections;
import java.util.Set;
import java.util.TreeSet;

import org.junit.Test;

public class CustomerPrint {
	
	public void customerPrintById(Set<Customer> set){        //按ID顺序打印
		Set<Customer> setById=new TreeSet<Customer>(new IdComparator());
		for (Customer c:set) {
			setById.add(c);
		}
		for (Customer c:setById) {
			System.out.println(c.id+"    "+c.name+"    "+c.mail+"    "+c.sex+"    "+c.birthday);
		}
		
		
	}
	
	public void customerPrintByBirthday(Set<Customer> set){     //按birthday顺序打印
		Set<Customer> setByBirthday=new TreeSet<Customer>(new BirthdayComparator());
		for (Customer c:set) {
			setByBirthday.add(c);
		}
		for (Customer c:setByBirthday) {
			System.out.println(c.id+"    "+c.name+"    "+c.mail+"    "+c.sex+"    "+c.birthday);
		}
		
		
	}
	
	public void customerPrintXMLFormat(Set<Customer> set){
		System.out.println("<Customer>");
		for (Customer c:set) {
			System.out.println("\t"+"<customer id="+c.id+">");
			System.out.println("\t\t"+"<customer name="+c.name+">");
			System.out.println("\t\t"+"<customer mail="+c.mail+">");
			System.out.println("\t\t"+"<customer sex="+c.sex+">");
			System.out.println("\t\t"+"<customer birthday="+c.birthday+">");
			System.out.println("\t"+"</customer>");
		}
		System.out.println("</Customer>");
		
	}

}
